{\rtf1\ansi\ansicpg936\cocoartf1344\cocoasubrtf720
{\fonttbl\f0\fswiss\fcharset0 Helvetica;\f1\froman\fcharset0 Times-Roman;\f2\fmodern\fcharset0 Courier;
\f3\fmodern\fcharset0 Courier-Oblique;}
{\colortbl;\red255\green255\blue255;\red0\green0\blue0;\red233\green237\blue203;\red11\green87\blue42;
\red255\green255\blue255;\red247\green247\blue247;\red2\green26\blue0;\red67\green67\blue67;\red20\green100\blue11;
\red90\green41\blue20;\red25\green0\blue208;\red147\green0\blue125;\red175\green8\blue21;}
{\*\listtable{\list\listtemplateid1\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{disc\}}{\leveltext\leveltemplateid1\'01\uc0\u8226 ;}{\levelnumbers;}\fi-360\li720\lin720 }{\listname ;}\listid1}
{\list\listtemplateid2\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{disc\}}{\leveltext\leveltemplateid101\'01\uc0\u8226 ;}{\levelnumbers;}\fi-360\li720\lin720 }{\listname ;}\listid2}
{\list\listtemplateid3\listhybrid{\listlevel\levelnfc0\levelnfcn0\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{decimal\}.}{\leveltext\leveltemplateid201\'02\'00.;}{\levelnumbers\'01;}\fi-360\li720\lin720 }{\listname ;}\listid3}}
{\*\listoverridetable{\listoverride\listid1\listoverridecount0\ls1}{\listoverride\listid2\listoverridecount0\ls2}{\listoverride\listid3\listoverridecount0\ls3}}
\paperw11900\paperh16840\margl1440\margr1440\vieww20780\viewh10920\viewkind0
\deftab720
\pard\pardeftab720\sl517\sa200

\f0\fs32 \cf2 \cb3 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 If you're new here, you may want to subscribe to my {\field{\*\fldinst{HYPERLINK "http://www.raywenderlich.com/feed/"}}{\fldrslt \cf4 \expnd0\expndtw0\kerning0
\ul \ulc4 \outl0\strokewidth0 \strokec4 RSS feed}} or follow me on {\field{\*\fldinst{HYPERLINK "http://twitter.com/rwenderlich"}}{\fldrslt \cf4 \expnd0\expndtw0\kerning0
\ul \ulc4 \outl0\strokewidth0 \strokec4 Twitter}}. Thanks for visiting!\cb1 \
\pard\pardeftab720\sl517
{\field{\*\fldinst{HYPERLINK "http://www.raywenderlich.com/2502/introduction-to-calayers-tutorial/layers-small"}}{\fldrslt \cf4 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec4 \
}}\pard\pardeftab720\sl400

\i \cf2 \cb5 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 Easily create rounded corners, shadows, and more by using CALayers!\cb1 \
\pard\pardeftab720\sl517

\i0 \cf2 \cb5 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 If you\'92ve been programming for the iPhone, you\'92re probably really familiar with UIViews \'96 buttons, text areas, sliders, web views, and more are all subclasses of UIView.\
But you might not know much about the technology that UIView is built upon: CALayers! At least I didn\'92t, for quite a while.\
It\'92s good to know a bit about CALayers, because you can use them to create some neat visual effects really easily. They\'92re also important to understand to work with Core Animation, which we\'92ll be discussing in a future tutorial.\
In this CALayers tutorial, you\'92re going to learn the basics of using CALayers by making a simple app to create a layer and experiment with how it looks. In the process, you\'92ll learn what layers are, some neat properties you can set, and how to put images and custom-drawn content inside.\
This CALayers tutorial assumes a basic familiarity with iPhone programming. If you are completely new, you might want to begin with the {\field{\*\fldinst{HYPERLINK "http://www.raywenderlich.com/?p=1797"}}{\fldrslt \cf4 \expnd0\expndtw0\kerning0
\ul \ulc4 \outl0\strokewidth0 \strokec4 How To Create A Simple iPhone App Tutorial Series}} first.\
So let\'92s get layering!\cb1 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \uc0\u8232 \cb5 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \
\pard\pardeftab720\sl517

\f1\b\fs52 \cf4 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec4 What Are CALayers?\
\pard\pardeftab720\sl517

\f0\b0\fs32 \cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 CALayers are simply classes representing a rectangle on the screen with visual content.\
\'93But wait a darn minute,\'94 you may say, \'93that\'92s what UIViews are for!\'94 That\'92s true, but there\'92s a trick to that: every UIView contains a root layer that it draws to! You can access this layer (created for you by default) with following bit of code:\

\itap1\trowd \taflags1 \trgaph108\trleft-108 \trbrdrt\brdrnil \trbrdrl\brdrnil \trbrdrt\brdrnil \trbrdrr\brdrnil 
\clvertalt \clshdrawnil \clwWidth14780\clftsWidth3 \clbrdrt\brdrnil \clbrdrl\brdrnil \clbrdrb\brdrnil \clbrdrr\brdrnil \clpadt40 \clpadl80 \clpadb40 \clpadr80 \gaph\cellx8640
\pard\intbl\itap1\pardeftab720\sl300

\f2\fs24 \cf2 \cb6 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 CALayer \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 *\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 myLayer \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 =\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2  myView.layer;\cb1 \cell \lastrow\row
\pard\pardeftab720\sl517

\f0\fs32 \cf2 \cb5 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 The neat thing about the CALayer class is that it contains a lot of properties that you can set on it to affect the visual appearance, such as:\
\pard\tx220\tx720\pardeftab720\li720\fi-720\sl517\sa200
\ls1\ilvl0\cf2 \kerning1\expnd0\expndtw0 \outl0\strokewidth0 {\listtext	\'95	}\expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 The size and position of the layer\cb1 \
\ls1\ilvl0\cb5 \kerning1\expnd0\expndtw0 \outl0\strokewidth0 {\listtext	\'95	}\expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 The layer\'92s background color\cb1 \
\ls1\ilvl0\cb5 \kerning1\expnd0\expndtw0 \outl0\strokewidth0 {\listtext	\'95	}\expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 The contents of the layer (an image, or something drawn with {\field{\*\fldinst{HYPERLINK "http://www.raywenderlich.com/?tag=core-graphics"}}{\fldrslt \cf8 \expnd0\expndtw0\kerning0
\ul \ulc8 \outl0\strokewidth0 \strokec8 Core Graphics}})\cb1 \
\ls1\ilvl0\cb5 \kerning1\expnd0\expndtw0 \outl0\strokewidth0 {\listtext	\'95	}\expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 Whether the corners of the layers should be rounded\cb1 \
\ls1\ilvl0\cb5 \kerning1\expnd0\expndtw0 \outl0\strokewidth0 {\listtext	\'95	}\expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 Settings for applying a drop shadow to the layer\cb1 \
\ls1\ilvl0\cb5 \kerning1\expnd0\expndtw0 \outl0\strokewidth0 {\listtext	\'95	}\expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 Applying a stroke around the edges of the layer\cb1 \
\ls1\ilvl0\cb5 \kerning1\expnd0\expndtw0 \outl0\strokewidth0 {\listtext	\'95	}\expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 And much more!\cb1 \
\pard\pardeftab720\sl517
\cf2 \cb5 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 You can use these properties to create some neat effects. For example, maybe you want to take an image, and put it in a white frame, and apply a shadow to it to make it look neat. Rather than whipping out Photoshop or creating a bunch of {\field{\*\fldinst{HYPERLINK "http://www.raywenderlich.com/?tag=core-graphics"}}{\fldrslt \cf4 \expnd0\expndtw0\kerning0
\ul \ulc4 \outl0\strokewidth0 \strokec4 Core Graphics}} code, you can do this {\field{\*\fldinst{HYPERLINK "http://tumbljack.com/post/506095243/subtle-effects-with-calayer"}}{\fldrslt \cf4 \expnd0\expndtw0\kerning0
\ul \ulc4 \outl0\strokewidth0 \strokec4 in a couple lines of code}}using CALayers!\
The other neat thing about the properties on CALayer is that most of them are animatable. For example, you could start your image out with rounded corners, tap a button, and have it animate the corners back out to straight. This can make for some really neat effects!\
You can use a CALayer on its own, or you can use one of the handy subclasses that are available, such as CAGradientLayer, CATextLayer, CAShapeLayer, and others. The default layer class for a UIView is the plain-old CALayer class, and that\'92s what you\'92ll be focusing on in this CALayers tutorial.\
\pard\pardeftab720\sl517

\f1\b\fs52 \cf4 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec4 Getting Started\
\pard\pardeftab720\sl517

\f0\b0\fs32 \cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 There\'92s no better way to understand using CALayers than to try them out yourself! So load up XCode, go to File\\New Project, choose iOS\\Application\\View-based Application, and click \'93Choose\'85\'94. Name the project LayerFun, and click Save.\
The View-based Application template starts with a single view controller, and as you know, each view controller has a root view. And as you learned above, every view has a root layer.\
So now you\'92ll try this out for yourself by changing some properties on the view\'92s layer.\
But first things first. To use CALayers and Core Animation, you need to use a framework that isn\'92t included by default in the View-based template: QuartzCore. So add it to your project by control-clicking the Frameworks group, selecting Add\\Existing Framework\'85, and choosing QuartzCore.framework from the dropdown list.\
Now that you\'92ve included QuartzCore, make the following changes to LayerFunViewController.m:\

\itap1\trowd \taflags1 \trgaph108\trleft-108 \trbrdrt\brdrnil \trbrdrl\brdrnil \trbrdrt\brdrnil \trbrdrr\brdrnil 
\clvertalt \clshdrawnil \clwWidth14780\clftsWidth3 \clbrdrt\brdrnil \clbrdrl\brdrnil \clbrdrb\brdrnil \clbrdrr\brdrnil \clpadt40 \clpadl80 \clpadb40 \clpadr80 \gaph\cellx8640
\pard\intbl\itap1\pardeftab720\sl300

\f3\i\fs24 \cf9 \cb6 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec9 // Import QuartzCore.h at the top of the file
\f2\i0 \cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 \
\pard\intbl\itap1\pardeftab720\sl300
\cf10 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec10 #import <QuartzCore/QuartzCore.h>\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 \
\'a0\
\pard\intbl\itap1\pardeftab720\sl300

\f3\i \cf9 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec9 // Uncomment viewDidLoad and add the following lines
\f2\i0 \cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 \
self.view.layer.backgroundColor \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 =\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2  \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 [\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 UIColor orangeColor\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 ]\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 .CGColor;\
self.view.layer.cornerRadius \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 =\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2  \cf11 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec11 20.0\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 ;\
self.view.layer.frame \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 =\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2  CGRectInset\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 (\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 self.view.layer.frame, \cf11 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec11 20\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 , \cf11 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec11 20\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 )\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 ;\cb1 \cell \lastrow\row
\pard\pardeftab720\sl517

\f0\fs32 \cf2 \cb5 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 Let\'92s go over this bit by bit since this is new stuff:\
\pard\tx220\tx720\pardeftab720\li720\fi-720\sl517\sa200
\ls2\ilvl0\cf2 \kerning1\expnd0\expndtw0 \outl0\strokewidth0 {\listtext	\'95	}\expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 To get a pointer to the layer for the view, you just use self.view.layer. Remember, you can the root view for a View Controller by calling self.view. Once you have the view, you can get its default layer (created automatically) by using view.layer. By default, the layer is a CALayer (not a subclass).\cb1 \
\ls2\ilvl0\cb5 \kerning1\expnd0\expndtw0 \outl0\strokewidth0 {\listtext	\'95	}\expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 Next you set the layer\'92s background color to orange. Note that the backgroundColor property actually takes a CGColor, but it\'92s easy to convert a UIColor to a CGColor by using the CGColor property.\cb1 \
\ls2\ilvl0\cb5 \kerning1\expnd0\expndtw0 \outl0\strokewidth0 {\listtext	\'95	}\expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 Next you round the corners a bit by setting the corner radius. The value you pass in is the radius of the circle which makes up the corner, and it chooses 20 here for a nice rounded edge.\cb1 \
\ls2\ilvl0\cb5 \kerning1\expnd0\expndtw0 \outl0\strokewidth0 {\listtext	\'95	}\expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 Finally, you shrink the frame a bit so it\'92s easier to see, by using the handy CGRectInset function. The CGRectInset function takes a frame and an amount to shrink it by (for both the X and Y), and returns a new frame.\cb1 \
\pard\pardeftab720\sl517
\cf2 \cb5 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 Compile and run your code, and you should see a rounded orange rectangle in the middle of your screen:\
\pard\pardeftab720\sl517
{\field{\*\fldinst{HYPERLINK "http://www.raywenderlich.com/2502/introduction-to-calayers-tutorial/simple-calayer"}}{\fldrslt \cf4 \cb1 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec4 }}\pard\pardeftab720\sl517
\cf2 \
\pard\pardeftab720\sl517

\f1\b\fs52 \cf4 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec4 CALayers and Sublayers\
\pard\pardeftab720\sl517

\f0\b0\fs32 \cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 Just like UIViews can have subviews, CALayers can have sublayers as well. You can create a new CALayer very easily with the following line of code:\

\itap1\trowd \taflags1 \trgaph108\trleft-108 \trbrdrt\brdrnil \trbrdrl\brdrnil \trbrdrt\brdrnil \trbrdrr\brdrnil 
\clvertalt \clshdrawnil \clwWidth14780\clftsWidth3 \clbrdrt\brdrnil \clbrdrl\brdrnil \clbrdrb\brdrnil \clbrdrr\brdrnil \clpadt40 \clpadl80 \clpadb40 \clpadr80 \gaph\cellx8640
\pard\intbl\itap1\pardeftab720\sl300

\f2\fs24 \cf2 \cb6 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 CALayer \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 *\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 sublayer \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 =\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2  \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 [\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 CALayer layer\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 ]\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 ;\cb1 \cell \lastrow\row
\pard\pardeftab720\sl517

\f0\fs32 \cf2 \cb5 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 Once you have a CALayer, you can set any properties on it you\'92d like. But remember there\'92s one property you definitely have to set: it\'92s frame (or bounds/position). After all, the layer needs to know how big it is (and where it\'92s located) in order to draw itself! When you\'92re done, you can add your new layer as a sublayer of another layer by the following line of code:\

\itap1\trowd \taflags1 \trgaph108\trleft-108 \trbrdrt\brdrnil \trbrdrl\brdrnil \trbrdrt\brdrnil \trbrdrr\brdrnil 
\clvertalt \clshdrawnil \clwWidth14780\clftsWidth3 \clbrdrt\brdrnil \clbrdrl\brdrnil \clbrdrb\brdrnil \clbrdrr\brdrnil \clpadt40 \clpadl80 \clpadb40 \clpadr80 \gaph\cellx8640
\pard\intbl\itap1\pardeftab720\sl300

\f2\fs24 \cf7 \cb6 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 [\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 myLayer addSublayer\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 :\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 sublayer\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 ]\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 ;\cb1 \cell \lastrow\row
\pard\pardeftab720\sl517

\f0\fs32 \cf2 \cb5 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 Ok, now try this out for yourself by adding a simple sublayer to the view\'92s layer. Add the following lines of code inside viewDidLoad, right after where you left off last time:\

\itap1\trowd \taflags1 \trgaph108\trleft-108 \trbrdrt\brdrnil \trbrdrl\brdrnil \trbrdrt\brdrnil \trbrdrr\brdrnil 
\clvertalt \clshdrawnil \clwWidth14780\clftsWidth3 \clbrdrt\brdrnil \clbrdrl\brdrnil \clbrdrb\brdrnil \clbrdrr\brdrnil \clpadt40 \clpadl80 \clpadb40 \clpadr80 \gaph\cellx8640
\pard\intbl\itap1\pardeftab720\sl300

\f2\fs24 \cf2 \cb6 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 CALayer *sublayer = [CALayer layer];\
sublayer.backgroundColor = [UIColor blueColor].CGColor;\
sublayer.shadowOffset = CGSizeMake(0, 3);\
sublayer.shadowRadius = 5.0;\
sublayer.shadowColor = [UIColor blackColor].CGColor;\
sublayer.shadowOpacity = 0.8;\
sublayer.frame = CGRectMake(30, 30, 128, 192);\
[self.view.layer addSublayer:sublayer];\cb1 \cell \lastrow\row
\pard\pardeftab720\sl517

\f0\fs32 \cf2 \cb5 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 This creates a new layer, and sets a few properties on it \'96 including a few you haven\'92t seen before to set shadows. You can see here how easy it is to set shadows on a layer \'96 which can give some amazing effects with very little effort!\
After setting the properties, it sets the frame of the layer and adds it as a sublayer to the view\'92s layer. Remember that these coordinates are relative to the parent layer\'92s frame, and since the parent layer begins at (20,20), the sublayer will be offset an additional (30,30) from that, so on the screen it will be at (50,50).\
Compile and run your code, and you should now see a blue sublayer on the screen!\
\pard\pardeftab720\sl517
{\field{\*\fldinst{HYPERLINK "http://www.raywenderlich.com/2502/introduction-to-calayers-tutorial/calayer-sublayer-with-shadow"}}{\fldrslt \cf4 \cb1 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec4 }}\pard\pardeftab720\sl517
\cf2 \
\pard\pardeftab720\sl517

\f1\b\fs52 \cf4 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec4 Setting CALayer Image Content\
\pard\pardeftab720\sl517

\f0\b0\fs32 \cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 One of the coolest things about CALayers is that they can contain more than just plain colors. It\'92s extremely easy to have them contain images instead, for example.\
So let\'92s replace the blue sublayer with an image instead. You can take a Default.jpg from one of your iPhone apps to use as a test, or you can {\field{\*\fldinst{HYPERLINK "http://d1xzuxjlafny7l.cloudfront.net/downloads/BattleMapSplashScreen.jpg"}}{\fldrslt \cf4 \expnd0\expndtw0\kerning0
\ul \ulc4 \outl0\strokewidth0 \strokec4 download a splash screen}} from one of my apps.\
Add the splash screen to your project, and inside viewDidLoad right before the last line you added that adds the sublayer to self.view.layer, add the following lines of code:\

\itap1\trowd \taflags1 \trgaph108\trleft-108 \trbrdrt\brdrnil \trbrdrl\brdrnil \trbrdrt\brdrnil \trbrdrr\brdrnil 
\clvertalt \clshdrawnil \clwWidth14780\clftsWidth3 \clbrdrt\brdrnil \clbrdrl\brdrnil \clbrdrb\brdrnil \clbrdrr\brdrnil \clpadt40 \clpadl80 \clpadb40 \clpadr80 \gaph\cellx8640
\pard\intbl\itap1\pardeftab720\sl300

\f2\fs24 \cf2 \cb6 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 sublayer.contents \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 =\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2  \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 (\cf12 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec12 id\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 )\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2  \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 [\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 UIImage imageNamed\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 :
\f3\i \cf9 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec9 @
\f2\i0 \cf13 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec13 "BattleMapSplashScreen.jpg"\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 ]\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 .CGImage;\
sublayer.borderColor \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 =\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2  \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 [\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 UIColor blackColor\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 ]\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 .CGColor;\
sublayer.borderWidth \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 =\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2  \cf11 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec11 2.0\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 ;\cb1 \cell \lastrow\row
\pard\pardeftab720\sl517

\f0\fs32 \cf2 \cb5 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 This sets the contents of the layer to an image (that\'92s literally all it takes!) and also sets the borderColor and borderWidth to set up a black stroke around the edges, to demonstrate how that works.\
Compile and run your code, and you should now see the blue layer\'92s contents replaced with your splash screen image!\
\pard\pardeftab720\sl517
{\field{\*\fldinst{HYPERLINK "http://www.raywenderlich.com/2502/introduction-to-calayers-tutorial/calayer-with-image-content"}}{\fldrslt \cf4 \cb1 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec4 }}\pard\pardeftab720\sl517
\cf2 \
\pard\pardeftab720\sl517

\f1\b\fs52 \cf4 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec4 A Note about Corner Radius and Image Content\
\pard\pardeftab720\sl517

\f0\b0\fs32 \cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 Now that you have this working, you might think it would be cool to round the corners of the splash screen as well, by setting the cornerRadius.\
Well the problem is that as far as I can tell, if you set that on a CALayer with image contents, the image will still be drawn outside the corner radius boundary. You can solve this by setting sublayer.masksToBounds to YES, but if you do that the shadows won\'92t show up because they\'92ll be masked out!\
I found a workaround by creating two layers. The outer layer is just a colored CALayer with a border and a shadow. The inner layer contains the image, and is also rounded but set up to mask. That way, the outer layer can draw the shadow, and the inner layer can contain the image.\
Try this out by modifying the code to create the sublayer as follows:\

\itap1\trowd \taflags1 \trgaph108\trleft-108 \trbrdrt\brdrnil \trbrdrl\brdrnil \trbrdrt\brdrnil \trbrdrr\brdrnil 
\clvertalt \clshdrawnil \clwWidth14780\clftsWidth3 \clbrdrt\brdrnil \clbrdrl\brdrnil \clbrdrb\brdrnil \clbrdrr\brdrnil \clpadt40 \clpadl80 \clpadb40 \clpadr80 \gaph\cellx8640
\pard\intbl\itap1\pardeftab720\sl300

\f2\fs24 \cf2 \cb6 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 CALayer \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 *\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 sublayer \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 =\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2  \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 [\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 CALayer layer\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 ]\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 ;\
sublayer.backgroundColor \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 =\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2  \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 [\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 UIColor blueColor\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 ]\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 .CGColor;\
sublayer.shadowOffset \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 =\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2  CGSizeMake\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 (\cf11 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec11 0\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 , \cf11 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec11 3\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 )\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 ;\
sublayer.shadowRadius \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 =\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2  \cf11 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec11 5.0\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 ;\
sublayer.shadowColor \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 =\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2  \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 [\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 UIColor blackColor\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 ]\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 .CGColor;\
sublayer.shadowOpacity \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 =\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2  \cf11 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec11 0.8\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 ;\
sublayer.frame \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 =\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2  CGRectMake\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 (\cf11 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec11 30\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 , \cf11 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec11 30\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 , \cf11 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec11 128\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 , \cf11 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec11 192\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 )\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 ;\
sublayer.borderColor \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 =\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2  \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 [\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 UIColor blackColor\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 ]\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 .CGColor;\
sublayer.borderWidth \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 =\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2  \cf11 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec11 2.0\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 ;\
sublayer.cornerRadius \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 =\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2  \cf11 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec11 10.0\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 ;\
\pard\intbl\itap1\pardeftab720\sl300
\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 [\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 self.view.layer addSublayer\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 :\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 sublayer\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 ]\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 ;\
\'a0\
CALayer \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 *\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 imageLayer \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 =\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2  \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 [\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 CALayer layer\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 ]\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 ;\
imageLayer.frame \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 =\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2  sublayer.bounds;\
imageLayer.cornerRadius \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 =\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2  \cf11 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec11 10.0\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 ;\
imageLayer.contents \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 =\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2  \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 (\cf12 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec12 id\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 )\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2  \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 [\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 UIImage imageNamed\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 :
\f3\i \cf9 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec9 @
\f2\i0 \cf13 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec13 "BattleMapSplashScreen.jpg"\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 ]\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 .CGImage;\
imageLayer.masksToBounds \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 =\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2  \cf12 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec12 YES\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 ;\
\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 [\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 sublayer addSublayer\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 :\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 imageLayer\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 ]\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 ;\cb1 \cell \lastrow\row
\pard\pardeftab720\sl517

\f0\fs32 \cf2 \cb5 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 Compile and run your code, and now your image will have rounded corners!\
\pard\pardeftab720\sl517
{\field{\*\fldinst{HYPERLINK "http://www.raywenderlich.com/2502/introduction-to-calayers-tutorial/calayer-with-image-content-and-corner-radius"}}{\fldrslt \cf4 \cb1 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec4 }}\pard\pardeftab720\sl517
\cf2 \
\pard\pardeftab720\sl517

\f1\b\fs52 \cf4 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec4 CALayer and Custom Drawn Content\
\pard\pardeftab720\sl517

\f0\b0\fs32 \cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 If you want to custom-draw the contents of a layer with Core Graphics instead of putting an image inside, that is quite easy too.\
The idea is you set a class as the delegate of the layer, and that class needs to implement a method named drawLayer:inContext. This can contain Core Graphics drawing code to draw anything you want in that space.\
Let\'92s try this out by adding a new layer, and drawing a pattern inside it. You\'92ll set the view controller as the delegate of the layer, and implement the drawLayer:inContext method to draw the pattern. As for the pattern drawing code, you\'92ll be using the same code as in the {\field{\*\fldinst{HYPERLINK "http://www.raywenderlich.com/?p=2167"}}{\fldrslt \cf4 \expnd0\expndtw0\kerning0
\ul \ulc4 \outl0\strokewidth0 \strokec4 Core Graphics 101: Patterns}} tutorial posted earlier on this site.\
Add the following code at the bottom of your viewDidLoad to add a new layer that will be custom drawn:\

\itap1\trowd \taflags1 \trgaph108\trleft-108 \trbrdrt\brdrnil \trbrdrl\brdrnil \trbrdrt\brdrnil \trbrdrr\brdrnil 
\clvertalt \clshdrawnil \clwWidth14780\clftsWidth3 \clbrdrt\brdrnil \clbrdrl\brdrnil \clbrdrb\brdrnil \clbrdrr\brdrnil \clpadt40 \clpadl80 \clpadb40 \clpadr80 \gaph\cellx8640
\pard\intbl\itap1\pardeftab720\sl300

\f2\fs24 \cf2 \cb6 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 CALayer \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 *\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 customDrawn \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 =\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2  \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 [\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 CALayer layer\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 ]\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 ;\
customDrawn.delegate \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 =\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2  self;\
customDrawn.backgroundColor \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 =\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2  \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 [\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 UIColor greenColor\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 ]\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 .CGColor;\
customDrawn.frame \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 =\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2  CGRectMake\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 (\cf11 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec11 30\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 , \cf11 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec11 250\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 , \cf11 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec11 128\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 , \cf11 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec11 40\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 )\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 ;\
customDrawn.shadowOffset \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 =\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2  CGSizeMake\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 (\cf11 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec11 0\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 , \cf11 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec11 3\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 )\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 ;\
customDrawn.shadowRadius \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 =\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2  \cf11 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec11 5.0\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 ;\
customDrawn.shadowColor \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 =\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2  \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 [\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 UIColor blackColor\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 ]\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 .CGColor;\
customDrawn.shadowOpacity \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 =\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2  \cf11 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec11 0.8\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 ;\
customDrawn.cornerRadius \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 =\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2  \cf11 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec11 10.0\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 ;\
customDrawn.borderColor \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 =\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2  \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 [\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 UIColor blackColor\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 ]\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 .CGColor;\
customDrawn.borderWidth \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 =\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2  \cf11 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec11 2.0\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 ;\
customDrawn.masksToBounds \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 =\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2  \cf12 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec12 YES\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 ;\
\pard\intbl\itap1\pardeftab720\sl300
\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 [\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 self.view.layer addSublayer\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 :\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 customDrawn\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 ]\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 ;\
\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 [\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 customDrawn setNeedsDisplay\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 ]\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 ;\cb1 \cell \lastrow\row
\pard\pardeftab720\sl517

\f0\fs32 \cf2 \cb5 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 Most of the code here you\'92ve seen before (creating a layer, setting properties such as shadow/cornerRadius/border/masksToBounds), however there are two new pieces:\
\pard\tx220\tx720\pardeftab720\li720\fi-720\sl517\sa200
\ls3\ilvl0\cf2 \kerning1\expnd0\expndtw0 \outl0\strokewidth0 {\listtext	1.	}\expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 First, it sets the delegate of the layer to self. This means that this object (self) will need to implement the drawLayer:inContext method to draw the contents of the layer.\cb1 \
\ls3\ilvl0\cb5 \kerning1\expnd0\expndtw0 \outl0\strokewidth0 {\listtext	2.	}\expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 Second, after it adds the layer, it needs to tell the layer to refresh itself (and call drawLayer:inContext) by calling setNeedsDisplay. If you forget to call this, drawLayer:inContext will never be called, so the pattern won\'92t show up!\cb1 \
\pard\pardeftab720\sl517
\cf2 \cb5 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 Next add the code to implement drawLayer:inContext, as shown below:\

\itap1\trowd \taflags1 \trgaph108\trleft-108 \trbrdrt\brdrnil \trbrdrl\brdrnil \trbrdrt\brdrnil \trbrdrr\brdrnil 
\clvertalt \clshdrawnil \clwWidth14780\clftsWidth3 \clbrdrt\brdrnil \clbrdrl\brdrnil \clbrdrb\brdrnil \clbrdrr\brdrnil \clpadt40 \clpadl80 \clpadb40 \clpadr80 \gaph\cellx8640
\pard\intbl\itap1\pardeftab720\sl300

\f2\fs24 \cf12 \cb6 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec12 void\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2  MyDrawColoredPattern \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 (\cf12 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec12 void\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2  \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 *\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 info, CGContextRef context\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 )\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2  \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 \{\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 \
\'a0\
    CGColorRef dotColor \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 =\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2  \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 [\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 UIColor colorWithHue\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 :\cf11 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec11 0\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2  saturation\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 :\cf11 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec11 0\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2  brightness\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 :\cf11 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec11 0.07\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2  alpha\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 :\cf11 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec11 1.0\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 ]\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 .CGColor;\
    CGColorRef shadowColor \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 =\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2  \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 [\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 UIColor colorWithRed\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 :\cf11 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec11 1\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2  green\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 :\cf11 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec11 1\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2  blue\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 :\cf11 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec11 1\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2  alpha\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 :\cf11 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec11 0.1\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 ]\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 .CGColor;\
\'a0\
    CGContextSetFillColorWithColor\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 (\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 context, dotColor\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 )\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 ;\
    CGContextSetShadowWithColor\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 (\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 context, CGSizeMake\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 (\cf11 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec11 0\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 , \cf11 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec11 1\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 )\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 , \cf11 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec11 1\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 , shadowColor\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 )\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 ;\
\'a0\
    CGContextAddArc\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 (\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 context, \cf11 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec11 3\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 , \cf11 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec11 3\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 , \cf11 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec11 4\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 , \cf11 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec11 0\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 , radians\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 (\cf11 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec11 360\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 )\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 , \cf11 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec11 0\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 )\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 ;\
    CGContextFillPath\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 (\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 context\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 )\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 ;\
\'a0\
    CGContextAddArc\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 (\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 context, \cf11 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec11 16\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 , \cf11 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec11 16\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 , \cf11 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec11 4\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 , \cf11 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec11 0\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 , radians\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 (\cf11 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec11 360\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 )\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 , \cf11 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec11 0\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 )\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 ;\
    CGContextFillPath\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 (\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 context\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 )\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 ;\
\'a0\
\pard\intbl\itap1\pardeftab720\sl300
\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 \}\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 \
\'a0\
\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 -\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2  \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 (\cf12 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec12 void\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 )\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 drawLayer\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 :(\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 CALayer \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 *)\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 layer inContext\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 :(\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 CGContextRef\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 )\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 context \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 \{\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 \
\'a0\
    CGColorRef bgColor \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 =\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2  \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 [\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 UIColor colorWithHue\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 :\cf11 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec11 0.6\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2  saturation\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 :\cf11 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec11 1.0\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2  brightness\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 :\cf11 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec11 1.0\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2  alpha\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 :\cf11 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec11 1.0\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 ]\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 .CGColor;\
    CGContextSetFillColorWithColor\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 (\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 context, bgColor\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 )\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 ;\
    CGContextFillRect\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 (\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 context, layer.bounds\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 )\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 ;\
\'a0\
    \cf12 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec12 static\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2  \cf12 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec12 const\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2  CGPatternCallbacks callbacks \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 =\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2  \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 \{\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2  \cf11 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec11 0\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 , \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 &\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 MyDrawColoredPattern, \cf12 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec12 NULL\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2  \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 \}\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 ;\
\'a0\
    CGContextSaveGState\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 (\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 context\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 )\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 ;\
    CGColorSpaceRef patternSpace \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 =\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2  CGColorSpaceCreatePattern\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 (\cf12 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec12 NULL\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 )\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 ;\
    CGContextSetFillColorSpace\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 (\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 context, patternSpace\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 )\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 ;\
    CGColorSpaceRelease\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 (\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 patternSpace\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 )\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 ;\
\'a0\
    CGPatternRef pattern \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 =\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2  CGPatternCreate\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 (\cf12 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec12 NULL\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 ,\
                                           layer.bounds,\
                                           CGAffineTransformIdentity,\
                                           \cf11 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec11 24\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 ,\
                                           \cf11 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec11 24\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 ,\
                                           kCGPatternTilingConstantSpacing,\
                                           \cf12 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec12 true\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 ,\
                                           \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 &\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 callbacks\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 )\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 ;\
    CGFloat alpha \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 =\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2  \cf11 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec11 1.0\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 ;\
    CGContextSetFillPattern\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 (\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 context, pattern, \cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 &\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 alpha\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 )\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 ;\
    CGPatternRelease\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 (\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 pattern\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 )\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 ;\
    CGContextFillRect\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 (\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 context, layer.bounds\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 )\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 ;\
    CGContextRestoreGState\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 (\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 context\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 )\cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 ;\
\cf7 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 \}\cf2 \cb1 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 \cell \lastrow\row
\pard\pardeftab720\sl517

\f0\fs32 \cf2 \cb5 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 This code is literally copied and pasted from the {\field{\*\fldinst{HYPERLINK "http://www.raywenderlich.com/?p=2167"}}{\fldrslt \cf4 \expnd0\expndtw0\kerning0
\ul \ulc4 \outl0\strokewidth0 \strokec4 Core Graphics 101: Patterns}} tutorial (just with a different color, and using the passed in context and layer bounds), so we aren\'92t going to cover it again here. If you want to know what it does, refer to the above tutorial.\
That\'92s it! Compile and run the code, and you should now see a blue grip pattern below the image.\
\pard\pardeftab720\sl517
{\field{\*\fldinst{HYPERLINK "http://www.raywenderlich.com/2502/introduction-to-calayers-tutorial/calayer-custom-drawn"}}{\fldrslt \cf4 \cb1 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec4 }}\pard\pardeftab720\sl517
\cf2 \
\pard\pardeftab720\sl517

\f1\b\fs52 \cf4 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec4 Where To Go From Here?\
\pard\pardeftab720\sl517

\f0\b0\fs32 \cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 Here is a {\field{\*\fldinst{HYPERLINK "http://d1xzuxjlafny7l.cloudfront.net/downloads/LayerFun.zip"}}{\fldrslt \cf4 \expnd0\expndtw0\kerning0
\ul \ulc4 \outl0\strokewidth0 \strokec4 sample project}} with all of the code we\'92ve developed in the above tutorial.\
At this point, you should be familiar with the concepts of CALayers and how to create some neat effects with them really easily. In future tutorials, I\'92ll show you how you can animate CALayers using Core Animation, and use some really handy subclasses of CALayer such as CAGradientLayer, CATextLayer, and CAShapeLayer.\
In the meantime, check out the {\field{\*\fldinst{HYPERLINK "http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CoreAnimation_guide/Introduction/Introduction.html"}}{\fldrslt \cf4 \expnd0\expndtw0\kerning0
\ul \ulc4 \outl0\strokewidth0 \strokec4 Core Animation Programming Guide}}, which does a great job talking about Core Animation, and more details about CALayers.\
If you\'92ve found some good ways to use CALayers in your projects, please share below! :]\
}